package com.lxd.controller;

import java.util.List;

import com.lxd.entity.query.MemberQuery;
import com.lxd.entity.po.Member;
import com.lxd.entity.vo.ResponseVO;
import com.lxd.service.MemberService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("memberController")
@RequestMapping("/member")
public class MemberController extends ABaseController{

	@Resource
	private MemberService memberService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(MemberQuery query){
		return getSuccessResponseVO(memberService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Member bean) {
		memberService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Member> listBean) {
		memberService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Member> listBean) {
		memberService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getMemberById")
	public ResponseVO getMemberById(Long id) {
		return getSuccessResponseVO(memberService.getMemberById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateMemberById")
	public ResponseVO updateMemberById(Member bean,Long id) {
		memberService.updateMemberById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteMemberById")
	public ResponseVO deleteMemberById(Long id) {
		memberService.deleteMemberById(id);
		return getSuccessResponseVO(null);
	}
}